@(virusLog: uk.bl.monitrix.model.VirusLog)

@import tags.{ navbar, embedParam }

@main("Monitrix - Virus Log") {
  @navbar("/viruses")
} {
  @defining(virusLog.getVirusRecords.toSeq) { viruses =>
    <h3>@viruses.size Viruses Detected During Crawl</h3>
    <table class="table table-condensed table-striped">
      <thead>
        <tr><th>Name</th><th># of Detections</th><th>Affected Hosts</th></tr>
      </thead>
      <tbody>
        @for(virusRecord <- viruses) {
          @defining(virusRecord.getOccurences.toSeq) { occurences =>
            <tr>
              <td><a href="http://www.google.com/search?q=@virusRecord.getName">@virusRecord.getName</a></td>
              <td>@occurences.foldLeft(0)(_ + _._2)</td>
              <td>
                @virusRecord.getOccurences.map { case (hostname, occurences) =>
                  <a href="@routes.Hosts.getHostInfo(hostname)@embedParam()">@hostname</a> (@occurences)<br/>
                }
              </td>
            </tr>
          }
        }
      </tbody>
    </table>
    <a href="viruses.pdf" class="btn btn-default pull-right">Download PDF</a>
  }
}